﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BizUserDALEntities;
using BizUserDAL;

namespace BizUser
{
    public partial class WebForm5 : System.Web.UI.Page
    {
        BizDAL currBiz = new BizDAL();
        BizInfo oBizInfo = new BizInfo();
        String dataForMsg;
        protected void Page_Load(object sender, EventArgs e)
        {
            
            oBizInfo= (BizInfo) Session["BizInfo"] ;
            loadObjectWithSessionValues();

            lblBizDetails.Text = dataForMsg;

            putValues();     
        }

        void putValues()
        {
            //function to put values in the labels of confirmation screen

            lblTitle.Text = oBizInfo.Title;
            lblBusinessType.Text = oBizInfo.BizTypeName;// Change to values


            lblAddress.Text = oBizInfo.Address1 + "," + oBizInfo.Address2 + "," + oBizInfo.CityName + "," + oBizInfo.StateName + "," + oBizInfo.CountryName + "," + oBizInfo.Zip;
            lblAskingPrice.Text = oBizInfo.AskingPriceLow + "-" + oBizInfo.AskingPriceHigh;
            lblDescription.Text = oBizInfo.Description;

            lblCashFlow.Text = oBizInfo.CashFlow.ToString();
            lblEBITDA.Text = oBizInfo.EBITDA.ToString();
            lblGrossIncome.Text = oBizInfo.GrossIncome.ToString();
            lblFurniture.Text = oBizInfo.FurnitureAndFixtures.ToString();
            lblInventory.Text = oBizInfo.Inventory.ToString();

            lblYear.Text = oBizInfo.YearEstablished.ToString();
            lblNumberOfEmployees.Text = oBizInfo.NoOfEmployees.ToString();

            lblReasonSelling.Text = oBizInfo.ReasonForSelling;


            lblAssetSale.Text = boolToString(oBizInfo.IsAssetSale);
            lblBrokerCoOp.Text = boolToString(oBizInfo.IsBrokerCoop);
            lblAbsentee.Text = boolToString(oBizInfo.IsAbsenteeRun);
            lblTrainingSupport.Text = boolToString(oBizInfo.IsTrainingAndSupportAvail);
            lblRelocatable.Text = boolToString(oBizInfo.IsRelocatable);
            lblRealEstate.Text = boolToString(oBizInfo.IsRealEstateAvail);
            lblRealEstateIncluded.Text = boolToString(oBizInfo.IsRealEstateIncluded);
            lblPartnershipAvailable.Text = boolToString(oBizInfo.IsParternshipAvail);
            lblOwnerFinancing.Text = boolToString(oBizInfo.IsOwnerFinancing);
            lblHomeBased.Text = boolToString(oBizInfo.IsHomeBased);
            lblFSBO.Text = boolToString(oBizInfo.IsFSBO);
            lblFranchise.Text = boolToString(oBizInfo.IsFranchise);
            

        }

        string boolToString(bool valToChange)
        {

            if (valToChange == true)
                return "Yes";
            else
                return "No";
        }

        void loadObjectWithSessionValues()
        {
            dataForMsg = "Title:" + oBizInfo.Title.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + "Business Type:" + oBizInfo.BizTypeID.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + "Asking Price Low:" + oBizInfo.AskingPriceLow.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + "Asking Price High:" + oBizInfo.AskingPriceHigh.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + "Relocatable:" + oBizInfo.IsRelocatable.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + "Hoem based:" + oBizInfo.IsHomeBased.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + "Real estate available:" + oBizInfo.IsRealEstateAvail.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + "Asset sale:" + oBizInfo.IsAssetSale.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + "Owner financing:" + oBizInfo.IsOwnerFinancing.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + "Absentee run:" + oBizInfo.IsAbsenteeRun.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + "Asking Price Low:" + oBizInfo.IsRealEstateIncluded.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.IsFSBO.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.IsBrokerCoop.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.IsTrainingAndSupportAvail.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.IsFinancialAssistanceAvail.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.IsParternshipAvail.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.IsFranchise.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.CountryID.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.StateID.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.CountyID.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.CityID.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.GrossIncome.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.CashFlow.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.EBITDA.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.FurnitureAndFixtures.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.Inventory.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.YearEstablished.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.NoOfEmployees.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.ReasonForSelling.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.ListedByUserID.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.Description.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.Address1.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.CreatedDT.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.UpdatedDT.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.IsActive.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.IsSold.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.ViewedCounter.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.IsForBuy.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.Zip.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.Address2.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.PostedDate.ToString() + Environment.NewLine;
            dataForMsg = dataForMsg + oBizInfo.InActiveDate.ToString() + Environment.NewLine;
            //  dataForMsg = dataForMsg + oBizInfo.Status.ToString() + Environment.NewLine;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            currBiz.SaveBizInfo(oBizInfo);
            lblMessage.Text = "Data updated suceessfully";
        }

       
    }
}